﻿using System;
using System.IO;
using System.Threading;
using Mono.Collections.Generic;

namespace Mono.Cecil
{
	// Token: 0x02000016 RID: 22
	public sealed class AssemblyDefinition : ICustomAttributeProvider, IMetadataTokenProvider, ISecurityDeclarationProvider, IDisposable
	{
		// Token: 0x1700001E RID: 30
		// (get) Token: 0x060000F3 RID: 243 RVA: 0x0000CF3C File Offset: 0x0000B13C
		// (set) Token: 0x060000F4 RID: 244 RVA: 0x00002BB2 File Offset: 0x00000DB2
		public AssemblyNameDefinition Name
		{
			get
			{
				return this.name;
			}
			set
			{
				this.name = value;
			}
		}

		// Token: 0x1700001F RID: 31
		// (get) Token: 0x060000F5 RID: 245 RVA: 0x0000CF54 File Offset: 0x0000B154
		public string FullName
		{
			get
			{
				return (this.name != null) ? this.name.FullName : string.Empty;
			}
		}

		// Token: 0x17000020 RID: 32
		// (get) Token: 0x060000F6 RID: 246 RVA: 0x0000CF80 File Offset: 0x0000B180
		// (set) Token: 0x060000F7 RID: 247 RVA: 0x00002A20 File Offset: 0x00000C20
		public MetadataToken MetadataToken
		{
			get
			{
				return new MetadataToken(TokenType.Assembly, 1);
			}
			set
			{
			}
		}

		// Token: 0x17000021 RID: 33
		// (get) Token: 0x060000F8 RID: 248 RVA: 0x0000CFA0 File Offset: 0x0000B1A0
		public Collection<ModuleDefinition> Modules
		{
			get
			{
				bool flag = this.modules != null;
				Collection<ModuleDefinition> result;
				if (flag)
				{
					result = this.modules;
				}
				else
				{
					bool hasImage = this.main_module.HasImage;
					if (hasImage)
					{
						result = this.main_module.Read<AssemblyDefinition, Collection<ModuleDefinition>>(ref this.modules, this, (AssemblyDefinition _, MetadataReader reader) => reader.ReadModules());
					}
					else
					{
						Interlocked.CompareExchange<Collection<ModuleDefinition>>(ref this.modules, new Collection<ModuleDefinition>(1)
						{
							this.main_module
						}, null);
						result = this.modules;
					}
				}
				return result;
			}
		}

		// Token: 0x17000022 RID: 34
		// (get) Token: 0x060000F9 RID: 249 RVA: 0x0000D034 File Offset: 0x0000B234
		public ModuleDefinition MainModule
		{
			get
			{
				return this.main_module;
			}
		}

		// Token: 0x17000023 RID: 35
		// (get) Token: 0x060000FA RID: 250 RVA: 0x0000D04C File Offset: 0x0000B24C
		// (set) Token: 0x060000FB RID: 251 RVA: 0x00002BBC File Offset: 0x00000DBC
		public MethodDefinition EntryPoint
		{
			get
			{
				return this.main_module.EntryPoint;
			}
			set
			{
				this.main_module.EntryPoint = value;
			}
		}

		// Token: 0x17000024 RID: 36
		// (get) Token: 0x060000FC RID: 252 RVA: 0x0000D06C File Offset: 0x0000B26C
		public bool HasCustomAttributes
		{
			get
			{
				bool flag = this.custom_attributes != null;
				bool result;
				if (flag)
				{
					result = (this.custom_attributes.Count > 0);
				}
				else
				{
					result = this.GetHasCustomAttributes(this.main_module);
				}
				return result;
			}
		}

		// Token: 0x17000025 RID: 37
		// (get) Token: 0x060000FD RID: 253 RVA: 0x0000D0A8 File Offset: 0x0000B2A8
		public Collection<CustomAttribute> CustomAttributes
		{
			get
			{
				return this.custom_attributes ?? this.GetCustomAttributes(ref this.custom_attributes, this.main_module);
			}
		}

		// Token: 0x17000026 RID: 38
		// (get) Token: 0x060000FE RID: 254 RVA: 0x0000D0D8 File Offset: 0x0000B2D8
		public bool HasSecurityDeclarations
		{
			get
			{
				bool flag = this.security_declarations != null;
				bool result;
				if (flag)
				{
					result = (this.security_declarations.Count > 0);
				}
				else
				{
					result = this.GetHasSecurityDeclarations(this.main_module);
				}
				return result;
			}
		}

		// Token: 0x17000027 RID: 39
		// (get) Token: 0x060000FF RID: 255 RVA: 0x0000D114 File Offset: 0x0000B314
		public Collection<SecurityDeclaration> SecurityDeclarations
		{
			get
			{
				return this.security_declarations ?? this.GetSecurityDeclarations(ref this.security_declarations, this.main_module);
			}
		}

		// Token: 0x06000100 RID: 256 RVA: 0x00002BCC File Offset: 0x00000DCC
		internal AssemblyDefinition()
		{
		}

		// Token: 0x06000101 RID: 257 RVA: 0x0000D144 File Offset: 0x0000B344
		public void Dispose()
		{
			bool flag = this.modules == null;
			if (flag)
			{
				this.main_module.Dispose();
			}
			else
			{
				Collection<ModuleDefinition> collection = this.Modules;
				for (int i = 0; i < collection.Count; i++)
				{
					collection[i].Dispose();
				}
			}
		}

		// Token: 0x06000102 RID: 258 RVA: 0x0000D198 File Offset: 0x0000B398
		public static AssemblyDefinition CreateAssembly(AssemblyNameDefinition assemblyName, string moduleName, ModuleKind kind)
		{
			return AssemblyDefinition.CreateAssembly(assemblyName, moduleName, new ModuleParameters
			{
				Kind = kind
			});
		}

		// Token: 0x06000103 RID: 259 RVA: 0x0000D1C0 File Offset: 0x0000B3C0
		public static AssemblyDefinition CreateAssembly(AssemblyNameDefinition assemblyName, string moduleName, ModuleParameters parameters)
		{
			bool flag = assemblyName == null;
			if (flag)
			{
				throw new ArgumentNullException("assemblyName");
			}
			bool flag2 = moduleName == null;
			if (flag2)
			{
				throw new ArgumentNullException("moduleName");
			}
			Mixin.CheckParameters(parameters);
			bool flag3 = parameters.Kind == ModuleKind.NetModule;
			if (flag3)
			{
				throw new ArgumentException("kind");
			}
			AssemblyDefinition assembly = ModuleDefinition.CreateModule(moduleName, parameters).Assembly;
			assembly.Name = assemblyName;
			return assembly;
		}

		// Token: 0x06000104 RID: 260 RVA: 0x0000D230 File Offset: 0x0000B430
		public static AssemblyDefinition ReadAssembly(string fileName)
		{
			return AssemblyDefinition.ReadAssembly(ModuleDefinition.ReadModule(fileName));
		}

		// Token: 0x06000105 RID: 261 RVA: 0x0000D250 File Offset: 0x0000B450
		public static AssemblyDefinition ReadAssembly(string fileName, ReaderParameters parameters)
		{
			return AssemblyDefinition.ReadAssembly(ModuleDefinition.ReadModule(fileName, parameters));
		}

		// Token: 0x06000106 RID: 262 RVA: 0x0000D270 File Offset: 0x0000B470
		public static AssemblyDefinition ReadAssembly(Stream stream)
		{
			return AssemblyDefinition.ReadAssembly(ModuleDefinition.ReadModule(stream));
		}

		// Token: 0x06000107 RID: 263 RVA: 0x0000D290 File Offset: 0x0000B490
		public static AssemblyDefinition ReadAssembly(Stream stream, ReaderParameters parameters)
		{
			return AssemblyDefinition.ReadAssembly(ModuleDefinition.ReadModule(stream, parameters));
		}

		// Token: 0x06000108 RID: 264 RVA: 0x0000D2B0 File Offset: 0x0000B4B0
		private static AssemblyDefinition ReadAssembly(ModuleDefinition module)
		{
			AssemblyDefinition assembly = module.Assembly;
			bool flag = assembly == null;
			if (flag)
			{
				throw new ArgumentException();
			}
			return assembly;
		}

		// Token: 0x06000109 RID: 265 RVA: 0x00002BD6 File Offset: 0x00000DD6
		public void Write(string fileName)
		{
			this.Write(fileName, new WriterParameters());
		}

		// Token: 0x0600010A RID: 266 RVA: 0x00002BE6 File Offset: 0x00000DE6
		public void Write(string fileName, WriterParameters parameters)
		{
			this.main_module.Write(fileName, parameters);
		}

		// Token: 0x0600010B RID: 267 RVA: 0x00002BF7 File Offset: 0x00000DF7
		public void Write()
		{
			this.main_module.Write();
		}

		// Token: 0x0600010C RID: 268 RVA: 0x00002C06 File Offset: 0x00000E06
		public void Write(WriterParameters parameters)
		{
			this.main_module.Write(parameters);
		}

		// Token: 0x0600010D RID: 269 RVA: 0x00002C16 File Offset: 0x00000E16
		public void Write(Stream stream)
		{
			this.Write(stream, new WriterParameters());
		}

		// Token: 0x0600010E RID: 270 RVA: 0x00002C26 File Offset: 0x00000E26
		public void Write(Stream stream, WriterParameters parameters)
		{
			this.main_module.Write(stream, parameters);
		}

		// Token: 0x0600010F RID: 271 RVA: 0x0000D2D8 File Offset: 0x0000B4D8
		public override string ToString()
		{
			return this.FullName;
		}

		// Token: 0x04000061 RID: 97
		private AssemblyNameDefinition name;

		// Token: 0x04000062 RID: 98
		internal ModuleDefinition main_module;

		// Token: 0x04000063 RID: 99
		private Collection<ModuleDefinition> modules;

		// Token: 0x04000064 RID: 100
		private Collection<CustomAttribute> custom_attributes;

		// Token: 0x04000065 RID: 101
		private Collection<SecurityDeclaration> security_declarations;
	}
}
